<template>
  <div>
    <button @click="isShow = !isShow">显示/隐藏</button>
    <!-- appear当打开页面时，动画便执行 -->
    <transition name="show" appear>
      <h1 v-show="isShow">你好啊！</h1>
    </transition>
  </div>
</template>

<script>
export default {
  name: "Test",
  data() {
    return {
      isShow: true,
    };
  },
};
</script>

<style scoped>
h1 {
  background-color: orange;
}
/* 如果transition有name则是.name-enter-active，如果没有则是.v-enter-active */
.show-enter-active {
  animation: show 1s;
}
.show-leave-active {
  animation: show 1s reverse;
}
@keyframes show {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}
</style>